﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataMappers;
using ExaminationTT.Model;


namespace ConcreteMappersAndObjects.DomainObjects
{
    public class CUnit : DomainObject<int, CUnit> , ICUnit
    {
        protected override CUnit Self()
        {
            //TODO check if necessary
            return this;
        }

        private string _acronym;
        private string _name;
        private IEnumerable<CUSemester> _semesters;
        private IEnumerable<Subscription> _subscritpions;
        private IEnumerable<CourseCU> _courses;
        private IEnumerable<TeacherClassCUnit> _tccus;

        public CUnit() : base()
        { 
        
        }

        public CUnit(int ID,
                    string acronym,
                    string name, 
                    IEnumerable<CUSemester> semesters, 
                    IEnumerable<Subscription> subscriptions, 
                    IEnumerable<CourseCU> courses,
                    IEnumerable<TeacherClassCUnit> tccus) : base(ID)
        {
            _acronym = acronym;
            _name = name;
            _semesters = semesters;
            _subscritpions = subscriptions;
            _courses = courses;
            _tccus = tccus;
        }

        #region ICUnit Members


        public string Acronym
        {
            get { return _acronym; }
            set { _acronym = value; MarkDirty(); }
            
        }

        public string Name
        {
            get { return _name; }
            set { _name = value; MarkDirty(); }
        }

        public IEnumerable<CUSemester> Semesters
        {
            get { return _semesters; }
        }

        public IEnumerable<CourseCU> Courses
        {
            get { return _courses; }
        }

        public IEnumerable<Subscription> Subscriptions
        {
            get { return _subscritpions; }
        }

        public IEnumerable<TeacherClassCUnit> TCCUs
        {
            get { return _tccus; }
        }

        #endregion

        #region ICUnit Members

        string ICUnit.Acronym
        {
            get { return _acronym; }
        }

        string ICUnit.Name
        {
            get { return _name; }
        }

        IEnumerable<ICUSemester> ICUnit.Semesters
        {
            get { return _semesters.ToList(); }
        }

        IEnumerable<ICourseCU> ICUnit.Courses
        {
            get { return _courses.ToList(); }
        }

        IEnumerable<ISubscription> ICUnit.Subscriptions
        {
            get { return _subscritpions.ToList(); }
        }

        #endregion
    }
}
